package com.cloudshadow.platform.server.common.uc.protocol.protocol;

import com.cloudshadow.platform.server.common.base.annotation.NoLogin;
import com.cloudshadow.platform.server.common.base.vo.BasicVo;
import com.cloudshadow.platform.server.common.base.vo.TokenVo;
import com.cloudshadow.platform.server.common.uc.protocol.Config;
import com.cloudshadow.platform.server.common.uc.protocol.Configuration;
import com.cloudshadow.platform.server.common.uc.protocol.UserFall;
import com.cloudshadow.platform.server.common.uc.protocol.model.UserModel;
import com.cloudshadow.platform.server.common.uc.protocol.req.UserAddReq;
import com.cloudshadow.platform.server.common.uc.protocol.req.UserLoginReq;
import com.cloudshadow.platform.server.common.uc.protocol.req.UserSearchReq;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by apple on 17/3/20.
 */
@FeignClient(name = Config.SERVER_NAME, path = UcProtocol.PATH, configuration = Configuration.class, fallback = UserFall.class)
public interface UcProtocol {
    public String PATH = "user";

    @RequestMapping(value = "findAll", method = RequestMethod.POST)
    public BasicVo<UserModel> findAll(@RequestBody UserSearchReq searchReq);

    @RequestMapping(value = "findOne", method = RequestMethod.POST)
    public BasicVo<UserModel> findOne(@RequestParam String id);

    @RequestMapping(value = "save", method = RequestMethod.POST)
    @NoLogin
    public BasicVo<UserModel> save(@RequestBody UserAddReq saveReq);

    @RequestMapping(value = "del", method = RequestMethod.POST)
    public BasicVo<UserModel> del(@RequestParam String id);

    @RequestMapping(value = "login", method = RequestMethod.POST)
    public BasicVo<TokenVo> login(@RequestBody UserLoginReq req);
}
